package com.dubboxml.gmail;

import com.dubbo.gmail.api.message.RequestDubboFactory;
import com.dubbo.gmail.api.service.HelloService;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.constants.CommonConstants;
import org.apache.dubbo.remoting.Constants;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class ConsumerMain {
    public static void main(String[] args) throws Exception {
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(new String[]{"spring-common.xml"});
        context.start();
        System.in.read();
        URL url = new URL("dubbo", "192.168.0.106", 20882).addParameter(Constants.CONNECT_TIMEOUT_KEY, 1000000)
                .addParameter(CommonConstants.TIMEOUT_KEY, 1000100);
        HelloService helloService = RequestDubboFactory.buildRequestDubbo(HelloService.class, context, url);
        String hello = helloService.sayHello("world"); // 执行远程方法
        System.out.println(hello); // 显示调用结果
    }
}
